﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;

namespace GiveGraphModel
{
    public class OrganizationLocation
    {
        public virtual Organization Organization { get; set; }
        public virtual Location Location { get; set; }
        public string Description { get; set; }

        public int OrganizationMemberId { get; set; }
        public int LocationId { get; set; }
    }

    public sealed class OrganizationLocationConfiguration : EntityTypeConfiguration<OrganizationLocation>
    {
        public OrganizationLocationConfiguration()
        {
            HasKey(p => new
                            {
                                p.OrganizationMemberId,
                                p.LocationId
                            })
           .HasRequired(p => p.Location)
                .WithMany()
                .HasForeignKey(p => p.LocationId);
            Property(ol => ol.Description);
            HasRequired(ol => ol.Organization);
        }
    }
}
